#ifndef JoystickBox_H
#define JoystickBox_H

#include <QWidget>
#include <QTimer>
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
#include <QList>

#include "qjoystick.h"
#include "comserie.h"

#define DEFAULT_SAMPLE_RATE 100

// Structure d'un joystick
struct joydata{
    unsigned int nb_axes;
    unsigned int nb_btn;
    QList<int> axis;
    QList<bool> button;
};

namespace Ui{
    class JoystickBox;
}

class JoystickBox : public QWidget {

    Q_OBJECT

public:
    JoystickBox(QWidget *parent = 0);
    ~JoystickBox();

    void init_joysticks();
    void getDataFromJoystick();
    QString currentJoystickName();
    joydata* currentJoystick();

private slots:
    void updateSelection(int index);
    void actionOnTimeout();
    void on_refreshButton_clicked();

signals:
    void joystickChanged();
    void xChanged(short);
    void yChanged(short);

private:
    void displayAxesValues();

    QList<joydata*> joysticksList;
    QJoystick *joy;
    QTimer *data_timer;
    QList<QLabel*> pbarlablist;
    int current_joystick;
    int nb_joy;
    bool connected;

    Ui::JoystickBox *ui;



};

#endif // JoystickBox_H
